package org.td.engine.combat.effect;

import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import org.td.engine.combat.Target;
import org.td.engine.entity.Entity;
import org.td.engine.entity.EntityEnvironment;
import org.td.engine.entity.Monster;
import org.td.engine.entity.ParticleFactory;

public class DamageEffect implements Effect {

    private float amount;

    public DamageEffect(float amount) {
        this.amount = amount;
    }

    @Override
    public void apply(Entity owner, Target target) {
        if (target instanceof Monster) {
            ((Monster)target).addHealth(-amount);

            EntityEnvironment env = ((Monster) target).getEntityEnvironment();
            ParticleFactory factory = env.getParticleFactory();
            ParticleEffect particleEffect = factory.createParticle("star");
            particleEffect.setPosition(target.getX(), target.getY());
            particleEffect.start();

            env.addParticle(particleEffect);

        } else {

        }
    }
}
